﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Homepage.Master" AutoEventWireup="true"
    CodeBehind="dangkythanhvien.aspx.cs" Inherits="LogisticSystem.dangkythanhvien" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cph_content" runat="server">
    <div class="title">
        &nbsp; &nbsp; &nbsp; ĐĂNG KÍ THÔNG TIN TÀI KHOẢN</div>
    <!--Title-->
    <div id="dangky">
        <div>
            <asp:ValidationSummary ID="vsThongBaoLoi" runat="server" />
        </div>
        <div id="thongbao">
        </div>
        <table id="table" style="border-style: outset; border-width: inherit; border-color: Olive;"
            width="600">
            <tr>
                <td colspan="2" height="25px">
                </td>
            </tr>
            <tr>
                <td class="td">
                    Tên đăng nhập :
                </td>
                <td>
                    <asp:TextBox ID="txtTenDangNhap" runat="server" MaxLength="50" Width="200px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvTenDangNhap" runat="server" ControlToValidate="txtTenDangNhap"
                        ErrorMessage="Lỗi chưa có tên đăng nhập.">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td class="td">
                    Mật khẩu :
                </td>
                <td>
                    <asp:TextBox ID="txtMatKhau1" runat="server" MaxLength="20" TextMode="Password" Width="200px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvMatKhau1" runat="server" ControlToValidate="txtMatKhau1"
                        ErrorMessage="Mật khẩu không được trống!">*</asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="revMatKhau1" runat="server" ControlToValidate="txtMatKhau1"
                        ErrorMessage="Mật khẩu phải từ 6 đến 20 kí tự." ForeColor="#006699" ValidationExpression=".{6,20}">*</asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td class="td">
                    Nhập lại mật khẩu :
                </td>
                <td>
                    <asp:TextBox ID="txtMauKhau2" runat="server" MaxLength="20" TextMode="Password" Width="200px"></asp:TextBox>
                    <asp:CompareValidator ID="cvMatKhau" runat="server" ControlToCompare="txtMatKhau1"
                        ControlToValidate="txtMauKhau2" ErrorMessage="Mật khẩu không khớp.">*</asp:CompareValidator>
                </td>
            </tr>
            <tr>
                <td class="td">
                    Họ và tên :
                </td>
                <td>
                    <asp:TextBox ID="txtHoTen" runat="server" MaxLength="50" Width="200px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvHoTen" runat="server" ControlToValidate="txtHoTen"
                        ErrorMessage="Lỗi chưa nhập họ tên.">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td class="td">
                    Email :
                </td>
                <td>
                    <asp:TextBox ID="txtEmail" runat="server" Width="200px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvEmail" runat="server" ControlToValidate="txtEmail"
                        ErrorMessage="Phải nhập địa chỉ mail!">*</asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="revEmail" runat="server" ControlToValidate="txtEmail"
                        ErrorMessage="Phải nhập một địa chỉ email!" ForeColor="#006699" ValidationExpression=".\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td class="td">
                    Ngày sinh :
                </td>
                <td>
                    <asp:ScriptManager ID="ScriptManager1" runat="server">
                    </asp:ScriptManager>
                    <asp:TextBox ID="txtNgaysinh" runat="server" Width="180px"></asp:TextBox>
                    <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtNgaysinh"
                        PopupButtonID="Imbtn">
                    </cc1:CalendarExtender>
                    <asp:ImageButton ID="Imbtn" runat="server" ImageUrl="~/Assets/Images/calender.png" />
                </td>
            </tr>
            <tr>
                <td class="td">
                    Chứng minh nhân dân :
                </td>
                <td>
                    <asp:TextBox ID="txtCmnd" runat="server" MaxLength="20" Width="200px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvCmnd" runat="server" ControlToValidate="txtCmnd"
                        ErrorMessage="Phải nhập số chứng minh nhân dân!">*</asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="revCmnd" runat="server" ControlToValidate="txtCmnd"
                        ErrorMessage="CMND phải nhập đúng 9 số!" ForeColor="Blue" ValidationExpression="\d{9}">*</asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td class="td">
                    Điện thoại liên lạc :
                </td>
                <td>
                    <asp:TextBox ID="txtSoDienThoai" runat="server" MaxLength="20" Width="200px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvDienThoai" runat="server" ControlToValidate="txtSoDienThoai"
                        ErrorMessage="Chưa điền số điện thoại">*</asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtSoDienThoai"
                        ErrorMessage="Số điện thoại phải có từ  6 đến 11 số! " ValidationExpression="\d{6,11}">*</asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td class="td">
                    Địa chỉ :
                </td>
                <td>
                    <asp:TextBox ID="txtDiaChi" runat="server" MaxLength="50" Width="200px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvDiaChi" runat="server" ControlToValidate="txtDiaChi"
                        ErrorMessage="Chưa nhập địa chỉ liên lạc!">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;
                </td>
                <td>
                    &nbsp; &nbsp;
                    <asp:Button ID="btnDangKy" runat="server" CssClass="button_submit" Text="Đăng Ký" />
                    &nbsp; &nbsp; &nbsp;
                    <input id="Reset1" onclick="return Reset1_onclick()" type="reset" class="button_reset"
                        value="Hủy bỏ" />
                </td>
            </tr>
        </table>
        <script type="text/javascript">
            var SERVICE_URL = "http://localhost:1237/LogisticsService.svc";
            $(function () {
                $("#<%=btnDangKy.ClientID%>").click(function () {
                    var username = $("#<%=txtTenDangNhap.ClientID%>").val();
                    //alert(username);
                    var password = $("#<%=txtMatKhau1.ClientID%>").val();
                    var hoten = $("#<%=txtHoTen.ClientID%>").val();
                    var email = $("#<%=txtEmail.ClientID%>").val();
                    email = email.replace('.', '-');
                    //alert(email);
                    var ngaysinh = $("#<%=txtNgaysinh.ClientID%>").val();
                    ngaysinh = ngaysinh.replace(/\//g, '-');
                    //alert(ngaysinh);
                    var cmnd = $("#<%=txtCmnd.ClientID%>").val();
                    var dienthoai = $("#<%=txtSoDienThoai.ClientID%>").val();
                    var diachi = $("#<%=txtDiaChi.ClientID%>").val();
                    diachi = diachi.replace(/\//g, '-');
                    //alert(diachi);

                    //call service
                    if (username != "" && hoten != "" && username != "" && ngaysinh != "" && cmnd != "" && email != "" && diachi != "" && dienthoai != "") {
                        var url = SERVICE_URL + "/themkhachhang/" + hoten + "/" + username + "/" + password + "/" + cmnd + "/" + dienthoai + "/" + email + "/" + ngaysinh + "/" + diachi;
                        $.get(url);
                        if ($.get(url)) {
                            alert('Bạn đã đăng ký thành công');
                        } else {
                            alert('Đăng ký đã thất bại!');
                        }
                    }

                });
            });
            //			function themKhResponse(responseData) {
            //				if (responseData == true) {
            //				    alert('Thêm khách hàng thành công');
            //				    window.location = "~/Default.aspx";
            //				}
            //				else
            //				    alert('Đăng ký thất bại!');
            //			}
        </script>
    </div>
    <p>
        &nbsp;</p>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cph_sidebar" runat="server">
</asp:Content>
